/*
 * @Description: 审批
 * @Author: Zzt
 * @Date: 2022-08-09 14:59:01
 * @LastEditTime: 2022-08-11 14:17:39
 */

import { ICommonDialog } from '@/interfaces/global';
import { Button, Form, Modal } from 'antd';
import { FC, useEffect } from 'react';
import TransferForm from './common/TransferForm';

interface ExamineFormProps extends ICommonDialog {
  data: any;
}
const ExamineForm: FC<ExamineFormProps> = (props) => {
  console.log('add transfer dialog', props.visible);
  const { visible, data, onClose } = props;
  const [form] = Form.useForm();

  useEffect(() => {
    if (visible) {
      //
    }
  }, [visible]);
  /**
   * @description: 关闭弹窗
   */
  const onCancel = () => {
    form.resetFields();
    onClose();
  };

  /**
   * @description 提交表单，触发onFinish方法
   */
  const submitFunc = () => {
    form.submit();
  };

  return (
    <Modal
      title="处理审批"
      visible={visible}
      width={600}
      destroyOnClose
      onCancel={onCancel}
      footer={[
        <Button key="close" onClick={onCancel}>
          取消
        </Button>,
        <Button
          key="create"
          type="primary"
          onClick={() => {
            submitFunc();
          }}
        >
          保存
        </Button>
      ]}
    >
      <TransferForm
        form={form}
        data={data}
        visible={visible}
        closeDialog={() => {
          onCancel();
        }}
        disabled={false}
      />
    </Modal>
  );
};
export default ExamineForm;
